package com.zzh.webhook.model;

import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data;

import java.util.List;

@Data
public class GitlabPushEvent {
    private String objectKind;
    private String eventName;
    private String before;
    private String after;
    private String ref;
    private String checkoutSha;
    private Integer userId;
    private String userName;
    private Integer projectId;
    private Repository repository;
    private List<Commit> commits;
    private Integer totalCommitsCount;

    @Data
    public static class Repository {
        private String name;
        private String url;
        private String description;
        private String homepage;
        private String gitHttpUrl;
        private String gitSshUrl;
        private Integer visibilityLevel;
    }

    @Data
    public static class Commit {
        private String id;
        private String message;
        private String title;
        private String timestamp;
        private String url;
        private Author author;
        private List<String> added;
        private List<String> modified;
        private List<String> removed;

        @Data
        public static class Author {
            private String name;
            private String email;
        }
    }

    public String getBranchName() {
        if (ref != null && ref.startsWith("refs/heads/")) {
            return ref.substring("refs/heads/".length());
        }
        return null;
    }
} 